import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import PlanGeneration from '../views/Maintenancemanagement/PlanGeneration.vue' //维保计划生成
import ModifyPlan from '../views/Maintenancemanagement/ModifyPlan.vue' //维保计划修改
import WorkGeneration from '../views/Maintenancemanagement/WorkGeneration.vue' //维保工单生成
import DeleteSchedule from '../views/Maintenancemanagement/DeleteSchedule.vue' //维保计划删除
import Elevatoraddition from '../views/Elevatormanagement/Elevatoraddition.vue' //电梯信息新增
import Elevatormaintenance from '../views/Elevatormanagement/Elevatormaintenance.vue' //电梯信息维护


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [{
	path: '/',
	component: Home,
	children: [
		{
			path: '',
			name: 'Welcome',
			component: () => import('@/components/welcome.vue')
		},
		{
			path: 'test',
			name: 'test',
			component: () => import('@/components/test.vue')
		},
		{
			path: '/association',
			name: 'association',
			component: () => import('@/components/association.vue')
		},
		//人员管理
		{
			path: '/PerManagement',
			name: 'perManagement',
			component: () => import('@/components/PerOrgManagement/perManagement.vue')
		},
		//权限管理
		{
			path: '/JurManagement',
			name: 'jurManagement',
			component: () => import('@/components/PerOrgManagement/jurManagement.vue')
		},
		//机构管理
		{
			path: '/OrgManagement',
			name: 'orgManagement',
			component: () => import('@/components/PerOrgManagement/orgManagement.vue')
		},
		//工作站管理
		{
			path: '/WorkManagement',
			name: 'workManagement',
			component: () => import('@/components/PerOrgManagement/workManagement.vue')
		},
		//部门管理
		{
			path: '/DepartManagement',
			name: 'departManagement',
			component: () => import('@/components/PerOrgManagement/departManagement.vue')
		},
		//班组管理
		{
			path: '/TeamManagement',
			name: 'teamManagement',
			component: () => import('@/components/PerOrgManagement/teamManagement.vue')
		},
		//维保细则
		{
			path: '/MaintenanceRules',
			name: 'maintenanceRules',
			component: () => import('@/components/MaintenanceRules/MaintenanceRules.vue')
		},

		//电梯定位
		{
			path: '/ElevatorLocation',
			name: 'elevatorLocation',
			component: () => import('@/components/MapPositioning/elevatorLocation.vue')
		},
		//工作站定位
		{
			path: '/WorkLocation',
			name: 'workLocation',
			component: () => import('@/components/MapPositioning/workLocation.vue')
		},
		//人员定位
		{
			path: '/PerLocation',
			name: 'perLocation',
			component: () => import('@/components/MapPositioning/perLocation.vue')
		},
		
		// 角色管理
		{
			path: '/roleManage',
			name: 'roleManage',
			component: () => import('@/components/SystemManagement/RolesPermissions/roleManage.vue')
		},
	
		// 用户授权管理
		{
			path: '/userManage',
			name: 'userManage',
			component: () => import('@/components/SystemManagement/RolesPermissions/userManage.vue')
		},
		// 资源管理
		{
			path: '/SysResource',
			name: 'SysResource',
			component: () => import('@/components/SystemManagement/RolesPermissions/SysResource.vue')
		},

		// 角色人员管理
		{
			path: '/rolePersonnelManage',
			name: 'rolePersonnelManage',
			component: () => import(
				'@/components/SystemManagement/RolesPermissions/rolePersonnelManage.vue')
		},
		// 菜单信息管理
		{
			path: '/menuManage',
			name: 'menuManage',
			component: () => import('@/components/SystemManagement/RolesPermissions/menuManage.vue')
		},


		// 维保工作计划---------------------------------------------------------------
		//维保计划生成
		{
			name: '/PlanGeneration',
			path: 'PlanGeneration',
			component: PlanGeneration
		},
		// 计划修改
		{
			name: '/ModifyPlan',
			path: 'ModifyPlan',
			component: ModifyPlan
		},
		// 工单生成
		{
			name: '/WorkGeneration',
			path: 'WorkGeneration',
			component: WorkGeneration
		},
		// 计划删除
		{
			name: '/DeleteSchedule',
			path: 'DeleteSchedule',
			component: DeleteSchedule
		},
	//电梯管理---------------------------------------------------------------------
	
		// 信息新增
		{
			name: '/Elevatoraddition',
			path: 'Elevatoraddition',
			component: Elevatoraddition
		},
		// 信息维护
		{
			name: '/Elevatormaintenance',
			path: 'Elevatormaintenance',
			component: Elevatormaintenance
		},
		
		
	]
},
{
	path: '/login',
	name: 'login',
	component: () => import('@/views/login.vue')
},
]

const router = new VueRouter({
	routes
})
// //为路由对象，添加beforeEach 导航守卫
// router.beforeEach((to, from, next) => {
// 	//如果用户访问的登录页，直接放行
// 	if (to.path === '/login') return next()
// 	//从sessionStorage 中获取到保存的token值
// 	const token = window.sessionStorage.getItem('token')
// 	//没有token,强制跳转到登录页
// 	if (!token) {
// 		if (to.path === '/culturalConstructionPub') {
// 			next()
// 		}
// 		else {
// 			return next('/login')
// 		}
// 	} { next() }
// })

export default router
